package com.example.rustfs.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;

/**
 * 分片上传记录
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UploadChunk {
    
    private String uploadId;          // 上传ID
    private Long userId;
    private String fileName;
    private String filePath;
    private Long totalSize;
    private Integer totalChunks;
    private Set<Integer> uploadedChunks = new HashSet<>();
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    
    public boolean isCompleted() {
        return uploadedChunks.size() == totalChunks;
    }
    
    public int getProgress() {
        if (totalChunks == 0) return 0;
        return (uploadedChunks.size() * 100) / totalChunks;
    }
}

